
#include "bedrosian_pyramid.hpp"

namespace neon
{
bedrosian_pyramid::bedrosian_pyramid(int const minimum_degree)
{
    switch (minimum_degree)
    {
        case 1:
        {
            m_degree = 1;

            m_weights = {4.0 / 3.0};
            m_coordinates = {{0, 0.0, 0.0, 0.25}};
            break;
        }
        case 2:
        case 3:
        {
            m_degree = 3;

            // A three point stencil on each triangle and two quadrature points
            // along the line element
            m_weights = {0.100785882079825,
                         0.232547451253508,
                         0.100785882079825,
                         0.232547451253508,
                         0.100785882079825,
                         0.232547451253508,
                         0.100785882079825,
                         0.232547451253508};

            m_coordinates = {{0, -0.263184055569714, -0.263184055569714, 0.544151844011225},
                             {1, -0.506616303349788, -0.506616303349788, 0.122514822655441},
                             {2, -0.263184055569714, 0.263184055569714, 0.544151844011225},
                             {3, -0.506616303349788, 0.506616303349788, 0.122514822655441},
                             {4, 0.263184055569714, -0.263184055569714, 0.544151844011225},
                             {5, 0.506616303349788, -0.506616303349788, 0.122514822655441},
                             {6, 0.263184055569714, 0.263184055569714, 0.544151844011225},
                             {7, 0.506616303349788, 0.506616303349788, 0.122514822655441}};

            break;
        }
        case 4:
        case 5:
        {
            m_degree = 5;

            // Three points on each triangle and three points along the line element
            m_weights = {0.009244044138450928, 0.045137737425884575, 0.048498876871878704,
                         0.01479047062152148,  0.0722203798814153,   0.07759820299500592,
                         0.009244044138450928, 0.045137737425884575, 0.048498876871878704,
                         0.01479047062152148,  0.0722203798814153,   0.07759820299500592,
                         0.02366475299443437,  0.11555260781026448,  0.12415712479200947,
                         0.01479047062152148,  0.0722203798814153,   0.07759820299500592,
                         0.009244044138450928, 0.045137737425884575, 0.048498876871878704,
                         0.01479047062152148,  0.0722203798814153,   0.07759820299500592,
                         0.009244044138450928, 0.045137737425884575, 0.048498876871878704};

            m_coordinates = {{0, -0.228504460573302, -0.228504460573302, 0.7050020098884979},
                             {1, -0.505808707853925, -0.505808707853925, 0.34700376603835204},
                             {2, -0.718055741319889, -0.718055741319889, 0.07299402407315003},
                             {3, -0.228504460573302, 0.0, 0.7050020098884979},
                             {4, -0.505808707853925, 0.0, 0.34700376603835204},
                             {5, -0.718055741319889, 0.0, 0.07299402407315003},
                             {6, -0.228504460573302, 0.228504460573302, 0.7050020098884979},
                             {7, -0.505808707853925, 0.505808707853925, 0.34700376603835204},
                             {8, -0.718055741319889, 0.718055741319889, 0.07299402407315003},
                             {9, 0.0, -0.228504460573302, 0.7050020098884979},
                             {10, 0.0, -0.505808707853925, 0.34700376603835204},
                             {11, 0.0, -0.718055741319889, 0.07299402407315003},
                             {12, 0.0, 0.0, 0.7050020098884979},
                             {13, 0.0, 0.0, 0.34700376603835204},
                             {14, 0.0, 0.0, 0.07299402407315003},
                             {15, 0.0, 0.228504460573302, 0.7050020098884979},
                             {16, 0.0, 0.505808707853925, 0.34700376603835204},
                             {17, 0.0, 0.718055741319889, 0.07299402407315003},
                             {18, 0.228504460573302, -0.228504460573302, 0.7050020098884979},
                             {19, 0.505808707853925, -0.505808707853925, 0.34700376603835204},
                             {20, 0.718055741319889, -0.718055741319889, 0.07299402407315003},
                             {21, 0.228504460573302, 0.0, 0.7050020098884979},
                             {22, 0.505808707853925, 0.0, 0.34700376603835204},
                             {23, 0.718055741319889, 0.0, 0.07299402407315003},
                             {24, 0.228504460573302, 0.228504460573302, 0.7050020098884979},
                             {25, 0.505808707853925, 0.505808707853925, 0.34700376603835204},
                             {26, 0.718055741319889, 0.718055741319889, 0.07299402407315003}};

            break;
        }
        case 6:
        case 7:
        {
            m_degree = 7;

            m_weights = {0.0012526521179532643, 0.008304905788749975,  0.017358942978834897,
                         0.013417830209662529,  0.0023484249849351022, 0.015569724404968645,
                         0.032543892130377255,  0.02515524243033622,   0.0023484249849351022,
                         0.015569724404968645,  0.032543892130377255,  0.02515524243033622,
                         0.0012526521179532643, 0.008304905788749975,  0.017358942978834897,
                         0.013417830209662529,  0.0023484249849351022, 0.015569724404968645,
                         0.032543892130377255,  0.02515524243033622,   0.004402738662094531,
                         0.02918953257423573,   0.06101206255962459,   0.04716010054094304,
                         0.004402738662094531,  0.02918953257423573,   0.06101206255962459,
                         0.04716010054094304,   0.0023484249849351022, 0.015569724404968645,
                         0.032543892130377255,  0.02515524243033622,   0.0023484249849351022,
                         0.015569724404968645,  0.032543892130377255,  0.02515524243033622,
                         0.004402738662094531,  0.02918953257423573,   0.06101206255962459,
                         0.04716010054094304,   0.004402738662094531,  0.02918953257423573,
                         0.06101206255962459,   0.04716010054094304,   0.0023484249849351022,
                         0.015569724404968645,  0.032543892130377255,  0.02515524243033622,
                         0.0012526521179532643, 0.008304905788749975,  0.017358942978834897,
                         0.013417830209662529,  0.0023484249849351022, 0.015569724404968645,
                         0.032543892130377255,  0.02515524243033622,   0.0023484249849351022,
                         0.015569724404968645,  0.032543892130377255,  0.02515524243033622,
                         0.0012526521179532643, 0.008304905788749975,  0.017358942978834897,
                         0.013417830209662529};

            m_coordinates = {{0, -0.1757997570095286, -0.1757997570095286, 0.795851417896773},
                             {1, -0.4158881109681957, -0.4158881109681957, 0.517047295104368},
                             {2, -0.655668552515022, -0.655668552515022, 0.23860073755186195},
                             {3, -0.819370727332981, -0.819370727332981, 0.048500549446997},
                             {4, -0.1757997570095286, -0.06940664798982377, 0.795851417896773},
                             {5, -0.4158881109681957, -0.16419476461254595, 0.517047295104368},
                             {6, -0.655668552515022, -0.2588613158318576, 0.23860073755186195},
                             {7, -0.819370727332981, -0.32349177616942704, 0.048500549446997},
                             {8, -0.1757997570095286, 0.06940664798982377, 0.795851417896773},
                             {9, -0.4158881109681957, 0.16419476461254595, 0.517047295104368},
                             {10, -0.655668552515022, 0.2588613158318576, 0.23860073755186195},
                             {11, -0.819370727332981, 0.32349177616942704, 0.048500549446997},
                             {12, -0.1757997570095286, 0.1757997570095286, 0.795851417896773},
                             {13, -0.4158881109681957, 0.4158881109681957, 0.517047295104368},
                             {14, -0.655668552515022, 0.655668552515022, 0.23860073755186195},
                             {15, -0.819370727332981, 0.819370727332981, 0.048500549446997},
                             {16, -0.06940664798982377, -0.1757997570095286, 0.795851417896773},
                             {17, -0.16419476461254595, -0.4158881109681957, 0.517047295104368},
                             {18, -0.2588613158318576, -0.655668552515022, 0.23860073755186195},
                             {19, -0.32349177616942704, -0.819370727332981, 0.048500549446997},
                             {20, -0.06940664798982377, -0.06940664798982377, 0.795851417896773},
                             {21, -0.16419476461254595, -0.16419476461254595, 0.517047295104368},
                             {22, -0.2588613158318576, -0.2588613158318576, 0.23860073755186195},
                             {23, -0.32349177616942704, -0.32349177616942704, 0.048500549446997},
                             {24, -0.06940664798982377, 0.06940664798982377, 0.795851417896773},
                             {25, -0.16419476461254595, 0.16419476461254595, 0.517047295104368},
                             {26, -0.2588613158318576, 0.2588613158318576, 0.23860073755186195},
                             {27, -0.32349177616942704, 0.32349177616942704, 0.048500549446997},
                             {28, -0.06940664798982377, 0.1757997570095286, 0.795851417896773},
                             {29, -0.16419476461254595, 0.4158881109681957, 0.517047295104368},
                             {30, -0.2588613158318576, 0.655668552515022, 0.23860073755186195},
                             {31, -0.32349177616942704, 0.819370727332981, 0.048500549446997},
                             {32, 0.06940664798982377, -0.1757997570095286, 0.795851417896773},
                             {33, 0.16419476461254595, -0.4158881109681957, 0.517047295104368},
                             {34, 0.2588613158318576, -0.655668552515022, 0.23860073755186195},
                             {35, 0.32349177616942704, -0.819370727332981, 0.048500549446997},
                             {36, 0.06940664798982377, -0.06940664798982377, 0.795851417896773},
                             {37, 0.16419476461254595, -0.16419476461254595, 0.517047295104368},
                             {38, 0.2588613158318576, -0.2588613158318576, 0.23860073755186195},
                             {39, 0.32349177616942704, -0.32349177616942704, 0.048500549446997},
                             {40, 0.06940664798982377, 0.06940664798982377, 0.795851417896773},
                             {41, 0.16419476461254595, 0.16419476461254595, 0.517047295104368},
                             {42, 0.2588613158318576, 0.2588613158318576, 0.23860073755186195},
                             {43, 0.32349177616942704, 0.32349177616942704, 0.048500549446997},
                             {44, 0.06940664798982377, 0.1757997570095286, 0.795851417896773},
                             {45, 0.16419476461254595, 0.4158881109681957, 0.517047295104368},
                             {46, 0.2588613158318576, 0.655668552515022, 0.23860073755186195},
                             {47, 0.32349177616942704, 0.819370727332981, 0.048500549446997},
                             {48, 0.1757997570095286, -0.1757997570095286, 0.795851417896773},
                             {49, 0.4158881109681957, -0.4158881109681957, 0.517047295104368},
                             {50, 0.655668552515022, -0.655668552515022, 0.23860073755186195},
                             {51, 0.819370727332981, -0.819370727332981, 0.048500549446997},
                             {52, 0.1757997570095286, -0.06940664798982377, 0.795851417896773},
                             {53, 0.4158881109681957, -0.16419476461254595, 0.517047295104368},
                             {54, 0.655668552515022, -0.2588613158318576, 0.23860073755186195},
                             {55, 0.819370727332981, -0.32349177616942704, 0.048500549446997},
                             {56, 0.1757997570095286, 0.06940664798982377, 0.795851417896773},
                             {57, 0.4158881109681957, 0.16419476461254595, 0.517047295104368},
                             {58, 0.655668552515022, 0.2588613158318576, 0.23860073755186195},
                             {59, 0.819370727332981, 0.32349177616942704, 0.048500549446997},
                             {60, 0.1757997570095286, 0.1757997570095286, 0.795851417896773},
                             {61, 0.4158881109681957, 0.4158881109681957, 0.517047295104368},
                             {62, 0.655668552515022, 0.655668552515022, 0.23860073755186195},
                             {63, 0.819370727332981, 0.819370727332981, 0.048500549446997}};
            break;
        }
        default:
        {
            throw std::domain_error("Bedrosian pyramid scheme only has a scheme up to 7th degree");
        }
    }
}
}
